package com.example.demo.publish;

import com.example.demo.entity.User;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
public class PublishTest {

    @Resource
    private ApplicationEventPublisher applicationEventPublisher;

    public void save(User user){

        if (true) {
            applicationEventPublisher.publishEvent(user);
            applicationEventPublisher.publishEvent(new Date());
        }
        // return "ok";
    }


}
